package cn.test.service;

import cn.test.processor.UserDao;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @auther hanchao
 * @date 2016/11/11 12:19
 */
@Service
public class UserService implements InitializingBean{
    private UserDao userDao;
    //@Autowired
    private HelloWorld helloWorld;

    public UserDao getUserDao() {
        return userDao;
    }
    @Autowired
    public void setUserDao(UserDao userDao) {
        System.out.println("设置属性");
        this.userDao = userDao;
    }

    public UserService(){
        System.out.println("userService实例化");
    }

    @PostConstruct
    public void init(){
        System.out.println("init函数");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("销毁函数");
    }

    //在init函数之后
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("属性设置完之后");
        //System.err.println(helloWorld.getClass());
        //helloWorld.sayHello();
    }
}
